<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生成绩</title>
    <meta name="context-path" th:content="@{/}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap-responsive.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-style.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-media.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-full.css}"/>
    <link rel="stylesheet" th:href="@{/resources/jquery-easyui/themes/metro/easyui.css}" />
    <link rel="stylesheet" th:href="@{/resources/matrix/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/resources/css/website.css}"/>
    <style>
        .layui-table-click{
            background-color: #FF7F24;
        }
    </style>
</head>
<body class="childbody">
<div class="container-fluid">
    <!--Chart-box-->
    <div class="row-fluid">
        <div class="widget-box">
            <div class="widget-title bg_lg"><span class="icon"><i class="icon-search"></i></span>
                <h5>查询</h5>
            </div>
            <div class="widget-content nopadding">
                <form id="queryform" action="#" method="get" class="form-horizontal query-form">
                    <input type="hidden" name="userId" th:value="*{userId}" >
                    <div class="row-fluid query-row">
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label">学生姓名：</label>
                                <div class="controls form-group">
                                    <input type="text" name="name" id="name" class="span11" placeholder="请输入学生姓名">
                                </div>
                            </div>
                        </div>
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label">学生学号：</label>
                                <div class="controls form-group">
                                    <input type="text" name="studentId" id="studentId" class="span11" placeholder="请输入学生学号">
                                </div>
                            </div>
                        </div>
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label query-control-label">考试期数：</label>
                                <div class="controls query-controls">
                                    <input type="text" name="term" id="term" class="span11" placeholder="请输入考试期数">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row-fluid query-row">
                        <div class="span3">
                            <div class="span3">
                                <div class="control-group">
                                    <label class="control-label">班级：</label>
                                    <div class="controls form-group">
                                        <select class="span6 form-control" id="county" name="clazzId">
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button id="btnSearch" type="button" class="btn btn-primary">查询</button>
                        <button id="btnResetSearch" type="button" class="btn btn-info">重置</button>
                    </div>
                </form>
            </div>
        </div>
        <!--End-Chart-box-->
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>学生成绩</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <button id="btnAdd" class="btn  btn-primary">添加</button>
                            <button id="btnEdit" class="btn btn-info">修改</button>
                            <button id="btnDelete" class="btn btn-danger">删除</button>
                            <button id="btnAddTerm" class="btn btn-success">按班级和考试期数添加</button>
                            <button id="btnImport"  type="button"  class="btn btn-success">学生成绩导入</button>
                            <!--<button id="btnView" class="btn btn-success">查看</button>
                            <button id="btnDoTop"  type="button"  class="btn btn-primary">置顶</button>
                            <button id="btnCancelTop"  type="button"  class="btn btn-success">取消置顶</button>
                            <button id="btnRelease" class="btn btn-info">发布</button>
                            <button id="btnDisabled" type="button" class="btn btn-danger">结束测评</button>
                            <button id="btnExport" class="btn btn-primary">导出</button>
                            <button id="btnImport"  type="button"  class="btn btn-success">导入</button>-->
                        </div>
                        <table id="tablelist" class="layui-table" lay-filter="question_list">
                        </table>
                    </div>
                </div>
            </div>

        </div>
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>科目分数</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <button id="btnAddItem" class="btn  btn-primary">添加</button>
                            <button id="btnEditItem" class="btn btn-info">修改</button>
                            <button id="btnDeleteItem" class="btn btn-danger">删除</button>
                        </div>
                        <table id="itemlist" class="layui-table" lay-filter="item_list">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/resources/js/jquery.min.js}"></script>
<script th:src="@{/resources/js/jquery-migrate-1.2.1.js}"></script>
<script th:src="@{/resources/jquery-easyui/jquery.easyui.min.js}"></script>
<script th:src="@{/resources/layui/layui.all.js}" charset="utf-8"></script>
<script th:src="@{/resources/valid/js/bootstrapValidator.js}"></script>
<script th:src="@{/resources/valid/js/language/zh_CN.js}"></script>
<script th:src="@{/resources/js/website.js}"></script>
<script th:src="@{/resources/js/system.js}"></script>
<script th:src="@{/resources/js/validation_fields.js}"></script>
<script th:inline="javascript">
    var contextRoot = $("meta[name='context-path']").attr("content");

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            search();
        }
    });
</script>

<script th:inline="javascript">
    /*<![CDATA[*/
    var query, add, edit, del, queryItem, addItem,editItem,deleteItem,questionId,questionItemId,addTerm,importExcel;
    layui.use(['jquery', 'layer', 'table', 'laydate'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table;

        lay('.date').each(function () {
            laydate.render({
                elem: this
            });
        });
        var cols = [
            [
                {type: 'checkbox'},
                {title:'学生姓名',width:'15%',event: 'getItem',templet: function(d){
                        if(d.student){
                            return d.student.name;
                        }
                        return "未知";
                    }
                },
                {field: 'clazzId', width: '15%',event: 'getItem',title: '班级', sort: true},
                {field: 'term', width: '15%',event: 'getItem', title: '考试期数', sort: true},
                {field: 'totalScore',event: 'getItem', width: '12%', title: '考试总分', sort: true},
                {field: 'avgScore',event: 'getItem', width: '12%', title: '考试平均分', sort: true},
                {field: 'subjectCount',event: 'getItem', width: '12%', title: '考试科目数', sort: true},
                {field: 'createTime',event: 'getItem', width: '15%', title: '创建时间', sort: true}
            ]
        ];
        query = new ListQuery(table, {
            cols: cols,
            element: "#tablelist",
            url: contextRoot + "studentAchieve/list",
            page: 1,
            even:false,
            filter: "question_list",
            tableid: "point_question_list_table",
            extraData: function () {
                return $("#queryform").serializeObject();
            },
            onRowChecked: function (row) {
                questionId = row.data.id;
                queryItem.reload();
            },
            onReload: function () {
                questionId = null;
            }
        });

        query.reload();

        add = new ListAdd(layer, {
            title: "添加成绩",
            url: contextRoot + "studentAchieve/getAddAchieve",
            width: "860px",
            height: "550px"
        }, query);

        edit = new ListEdit(layer, {
            title: "修改成绩",
            url: contextRoot + "studentAchieve/getUpdateAchieve",
            width: "860px",
            height: "550px"
        }, query);

        del = new ListDelete(layer, query, {
            url: contextRoot + "studentAchieve/doDeleteAchieve"
        });

        importExcel = new ListAdd(layer, {
            title: "导入学生成绩",
            url: contextRoot + "studentAchieve/goFileUpload",
            width: "860px",
            height: "350px"
        }, query);

        $("#btnResetSearch").bind("click", function (event) {
            $("#name").val("");
            $("#studentId").val("");
            $("#term").val("");
            $("#county").combotree('setValues',"");

        });

        addTerm = new ListAdd(layer, {
            title: "按班级和考试期数批量添加成绩",
            url: contextRoot + "studentAchieve/getAddAchieveByTerm",
            width: "800px",
            height: "550px"
        }, query);

        $("#btnDelete").bind("click", function (event) {
            del.submit();
        });

        $("#btnEdit").bind("click", function (event) {
            edit.openDialog();
        });

        $("#btnAdd").bind("click", function (event) {
            add.openDialog();
        });

        $("#btnSearch").bind("click", function (event) {
            query.reload();
        });

        $("#btnAddTerm").bind("click", function (event) {
            addTerm.openDialog();
        });

        $("#btnImport").bind("click", function (event) {
            importExcel.openDialog();
        });
        //item
        var colItems = [
            [
                {type: 'checkbox'},
                {title:'科目',width:'15%',templet: function(d){
                        if(d.subject){
                            return d.subject.name;
                        }
                        return "未知";
                    }
                },
                {field: 'score', width: '20%', title: '分数', sort: true},
                {field: 'createTime', width: '25%', title: '创建时间', sort: true},
                {field: 'description', width: '20%', title: '描述', sort: true}
            ]
        ];
        queryItem = new ListQuery(table, {
            cols: colItems,
            element: "#itemlist",
            url: contextRoot + "studentScore/doListScoreItem",
            page: 1,
            even:false,
            filter: "item_list",
            single: true,
            pageable: false,
            tableid: "question_item_list_table",
            extraData: function () {
                return {parentId: questionId};
            },
            onRowChecked: function (row) {
                questionItemId = row.data.id;
            },
            onReload: function () {
                questionItemId = null;
            }

        });

        addItem = new ListAdd(layer, {
            title: "添加科目分数",
            url: contextRoot + "studentScore/getAddScoreItem",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + questionId;
            }
        }, queryItem);

        editItem = new ListEdit(layer, {
            title: "修改科目分数",
            url: contextRoot + "studentScore/getUpdateItem",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + questionId;
            }
        }, queryItem);

        deleteItem = new ListDelete(layer, queryItem, {
            url: contextRoot + "studentScore/doDeleteItem"
        });

        $("#btnAddItem").bind("click", function (event) {
            if (questionId) {
                addItem.openDialog();
            }
        });

        $("#btnEditItem").bind("click", function (event) {
            if (questionId) {
                editItem.openDialog();
            }
        });

        $("#btnDeleteItem").bind("click", function (event) {
            deleteItem.submit();
        });
        $('#county').combotree({
            url: contextRoot + "jwOrg/doClazzListTreeOrgByUser",
            required: true
        });
    });
    /*]]>*/
</script>
</body>
</html>